Function override_OKcodeset (GUI_object,value) 	
	GUI_object.set value
   	TestLogEngine.LogEvent "Done",GUI_object.GetROProperty("micclass"),"(OKcode).Set: " & value
End Function


Function override_set (GUI_object,value) 	
	GUI_object.set value
   	TestLogEngine.LogEvent "Done",GUI_object.GetROProperty("micclass"),"("&GUI_object.GetROProperty("attachedtext")& ").Set: " & value
End Function


Function override_click (GUI_object)
'	TestLogEngine.LogEvent "Done",GUI_object.GetROProperty("micclass"),"("& GUI_object.GetROProperty("tooltip") & ").Click "	
'	GUI_object.click	
	On Error Resume Next
	Err.clear
	Dim start_time
	Set oObject = ConvertObject (strWindow, strObject)
	If not isobject(oObject) Then
		ClickObject = "Error|"&CurrentTime()&"|Convert object failed."
		Set oObject = Nothing
		Exit Function
	Else
		start_time=Time()
		Do while TimeCount(start_time)<cint(environment("TIME_OUT"))
			If DoesObjectExist(oObject) Then
				Exit do
			End If
		Loop
		If TimeCount(start_time)>=cint(environment("TIME_OUT")) Then
			ClickObject="Error|"&CurrentTime()&"|Can't find the object."
			Set oObject = Nothing
			Exit Function
		End If
		oObject.Click
		wait(1)
		If err.number = 0 Then
			ClickObject="Pass|"&CurrentTime()&"|Click "&"the button/link " &Chr(34)&strObject&Chr(34)&" object successfully."
			ResulteArray=CurrentTime()&"|Click "&"the button/link " &Chr(34)&strObject&Chr(34)&" object successfully."&Chr(64)&Chr(64)&ResulteArray
		Else
			ClickObject="Error|"&CurrentTime()&"|Click object failed."&Err.number&" "&Err.description
			ResulteArray=CurrentTime()&"|Click "&"the button/link " &Chr(34)&strObject&Chr(34)&" object successfully."&Chr(64)&Chr(64)&ResulteArray
		End If
	End If
	ReArrayLens=ReArrayLens+1
'	msgbox ResulteArray 'ResulteArray,ReArrayNum,ReArray
'    ReArray = Split(ResulteArray, "@@")
'
'	For  ReArrayLens To  0  'daoxu    'ReArrayNum=0 To  ReArrayLens
'    msgbox ReArray(ReArrayNum)
'	ReArrayNum=ReArrayNum+1
'	Next
	Set oObject = Nothing
End Function

Function override_select (GUI_object,value)	
	GUI_object.select value
	TestLogEngine.LogEvent "Done",GUI_object.GetROProperty("micclass"),"("&GUI_object.GetROProperty("attachedtext")& ").Selet: " & value
End Function

'only for SAPGuiSession
Function override_Reset (GUI_object,value)
	GUI_object.Reset value
	if GUI_object.SAPGuiWindow("type:=GuiMainWindow").exist(2) then
		TestLogEngine.LogEvent "Done","SAPGuiSession","(Session).Reset: " &value & " -> Current Window: "& GUI_object.SAPGuiWindow("type:=GuiMainWindow").getroproperty("text")
	else
		TestLogEngine.LogEvent "Done","SAPGuiSession","(Session).Reset: " &value & " -> Current Window: "& GUI_object.SAPGuiWindow("type:=GuiModalWindow").getroproperty("text")
	end if
End Function

'only for SAPGuiWindow
Function override_Sendkey(GUI_object,key)	
	Select Case key
		case ENTER
			tmpkey = "Enter"
		case F1
			tmpkey = "F1"
			case F1
			tmpkey = "F1"
		case F2
			tmpkey = "F2"
		case F3
			tmpkey = "F3"
		case F4
			tmpkey = "F4"
		case F5
			tmpkey = "F5"
		case F6
			tmpkey = "F6"
		case F7
			tmpkey = "F7"		
		case F8
			tmpkey = "F8"
		case F9
			tmpkey = "F9"
		case F10
			tmpkey = "F10"
		case F11
			tmpkey = "F11"
		case ESC 
			tmpkey = "ESC"
		case SHIFT_F1 
			tmpkey = "SHIFT_F1"			
		case SHIFT_F2 
			tmpkey = "SHIFT_F2"			
		case SHIFT_F3 
			tmpkey = "SHIFT_F3"			
		case SHIFT_F4 
			tmpkey = "SHIFT_F4"
		case SHIFT_F5 
			tmpkey = "SHIFT_F5"
		case SHIFT_F6 
			tmpkey = "SHIFT_F6"			
		case SHIFT_F7 
			tmpkey = "SHIFT_F7"			
		case SHIFT_F8 
			tmpkey = "SHIFT_F8"			
		case SHIFT_F9 
			tmpkey = "SHIFT_F9"			
		case SHIFT_F10 
			tmpkey = "SHIFT_F10"
		case SHIFT_F11 
			tmpkey = "SHIFT_F11"
		case SHIFT_F12 
			tmpkey = "SHIFT_F12"
		case PAGEDOWN 
			tmpkey = "PAGEDOWN"			
		case PAGEUP  
			tmpkey = "PAGEUP"
		case CTRL_F  
			tmpkey = "CTRL_F"
		case CTRL_G  
			tmpkey = "CTRL_G"			
		case CTRL_P  
			tmpkey = "CTRL_P"
		case CTRL_PAGEDOWN  
			tmpkey = "CTRL_PAGEDOWN"
		case CTRL_PAGEUP  
			tmpkey = "CTRL_PAGEUP"
		Case else
			tmpkey = "Invalid key"
		End select			
	TestLogEngine.LogEvent "Done","SAPGuiWindow","(" &GUI_object.getroproperty("text") & ").Sendkey: " & tmpkey
	GUI_object.Sendkey key
End Function

'only for GuiStatusbar
Function override_Sync(GUI_object)
	GUI_object.Sync
	dim tmpStatus,tmpText
	tmpText = GUI_object.getroproperty("text")
	tmpStatus = GUI_object.getroproperty("messagetype")
	if tmpText<>"" then
		select case tmpStatus
			case "W"
				TestLogEngine.LogEvent "Warning","SAPGuiStatusbar","(StatusBar).Sync ->" & tmpText
			case "E"
				TestLogEngine.LogEvent "Fail","SAPGuiStatusbar","(StatusBar).Sync ->" & tmpText
			Case else
				TestLogEngine.LogEvent "Pass","SAPGuiStatusbar","(StatusBar).Sync ->" & tmpText
		end select
	else 
		TestLogEngine.LogEvent "Done","SAPGuiStatusbar","(StatusBar).Sync"
	end if	
End Function

'only for SAPGuiMenubar
function override_MenubarSelect(GUI_object,value)
	GUI_object.Select value
	TestLogEngine.LogEvent "Done","SAPGuiMenubar","(mbar).Select: " & value
End Function

'only for SAPGuiTabStrip



'only for SAPGuiTable
Function override_Table_SetCellData(GUI_object,irow,strColumn,value)
	GUI_object.SetCellData irow,strColumn,value
	TestLogEngine.LogEvent "Done","SAPGuiTable","("& replace(GUI_object.toString," table","") &").SetCellData: " & irow &","&strColumn &"," & value
End Function

Function override_Table_ClickCell(GUI_object,irow,strColumn)
	GUI_object.ClickCell irow,strColumn
	TestLogEngine.LogEvent "Done","SAPGuiTable","("& replace(GUI_object.toString," table","") &").ClickCell: " & irow &","&strColumn 
End Function

Function override_Table_SelectRow(GUI_object,irow)
	GUI_object.SelectRow irow
	TestLogEngine.LogEvent "Done","SAPGuiTable","("& replace(GUI_object.toString," table","") &").SelectRow: " & irow 
End Function



Function OverrideFunctions()
	'Set
	RegisterUserFunc "SAPGuiSession","Reset","override_Reset"
	RegisterUserFunc "SAPGuiOKCode", "Set", "override_OKcodeset" 
	RegisterUserFunc "SAPGuiTextArea", "Set", "override_set" 
	RegisterUserFunc "SAPGuiEdit", "Set", "override_set" 
	RegisterUserFunc "SAPGuiCheckBox", "Set", "override_set" 
	
	'click
	RegisterUserFunc "SAPGuiButton", "click", "override_click" 
	
	'select
	RegisterUserFunc "SAPGuiComboBox", "select","override_select"
	'RegisterUserFunc "SAPGuiTabStrip ", "select","override_select"
	
	'table
	RegisterUserFunc "SAPGuiTable","SetCellData","override_Table_SetCellData"
	RegisterUserFunc "SAPGuiTable","ClickCell","override_Table_ClickCell"
	RegisterUserFunc "SAPGuiTable","SelectRow","override_Table_SelectRow"
	
	'Other
	RegisterUserFunc "SAPGuiWindow","Sendkey","override_Sendkey"
	RegisterUserFunc "SAPGuiStatusbar","Sync","override_Sync"
	RegisterUserFunc "SAPGuiMenubar","Select","override_MenubarSelect"
End Function

Function UnRegisterFunctions()
	'set
	UnRegisterUserFunc "SAPGuiSession","Reset"
	UnRegisterUserFunc "SAPGuiOKCode", "Set" 
	UnRegisterUserFunc "SAPGuiTextArea","Set"
	UnRegisterUserFunc "SAPGuiEdit", "Set"
	UnRegisterUserFunc "SAPGuiCheckBox", "Set"
	
	'click
	UnRegisterUserFunc "SAPGuiButton", "click"
	
	'Select
	UnRegisterUserFunc "SAPGuiComboBox ", "select"
	'UnRegisterUserFunc "SAPGuiTabStrip ", "select"
	
	'table
	UnRegisterUserFunc "SAPGuiTable","SetCellData"
	UnRegisterUserFunc "SAPGuiTable","ClickCell"
	UnRegisterUserFunc "SAPGuiTable","SelectRow"
	
	
	UnRegisterUserFunc "SAPGuiWindow","Sendkey"
	UnRegisterUserFunc "SAPGuiStatusbar","Sync"
	UnRegisterUserFunc "SAPGuiMenubar","Select"
	
End Function